-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address signingCert panic with the last-byte calculation of finalChainPEM #370
Conversation
Signed-off-by: Thomas Stromberg <t+github@stromberg.org>
pkg/api/ca.go
Outdated
@@ -213,7 +213,7 @@ func (a *api) signingCert(w http.ResponseWriter, req *http.Request) { | |||
} | |||
if len(finalChainPEM) > 0 { | |||
fmt.Fprintf(&ret, "%s", finalChainPEM) | |||
if finalPEM[len(finalChainPEM)-1] != '\n' { | |||
if finalChainPEM[len(finalChainPEM)-1] != '\n' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Perhaps this might be more clear if we'd written as
if finalChainPEM[len(finalChainPEM)-1] != '\n' { | |
if !strings.HasSuffix(string(finalChainPEM), "\n") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea. Done!
Signed-off-by: Thomas Stromberg <t+github@chainguard.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! I had added this check. This suggests to me we need some additional tests.
@bobcallaway @dlorenc - Not sure when the last Fulcio release was, but if it's been pushed after 10262db, we'll want to get this change in and pushed. |
Ack, deploying after this one! |
Signed-off-by: Thomas Stromberg t+github@stromberg.org
Summary
Addresses a panic caused by the incorrect string being referred for a newline check.
This panic only occurs if finalPEM is shorter than finalChainPEM.
Ticket Link
Fixes #369
Release Note